package ar.edu.unicen.exa.isistan.archassis.diff;

import java.io.File;

import jdiff.JDiffAntTask.ProjectInfo;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;

public class JDiffData {
	/**
	 * The JDiff Ant task does not inherit from an Ant task, such as the 
	 * Javadoc task, though this is usually how most Tasks are
	 * written. This is because JDiff needs to run Javadoc three times
	 * (twice for generating XML, once for generating HTML). The
	 * Javadoc task has not easy way to reset its list of packages, so
	 * we needed to be able to crate new Javadoc task objects.
	 *
	 * Note: Don't confuse this class with the ProjectInfo used by JDiff. 
	 * This Project class is from Ant.
	 */
	private Project project;

	/**
	 * Used as part of Ant's startup.
	 */
	public void setProject(Project proj) {
		project = proj;
	}
	public Project getProject() {
		return project;
	}
	
	/**
	 * Allow the source language version to be specified.
	 */
	private String source = "1.5"; // Default is 1.5, so generics will work

	public void setSource(String source) {
		this.source = source;
	}

	public String getSource() {
		return source;
	}
	
	/**
	 * A ProjectInfo-derived object for the older version of the project
	 */
	private ProjectInfo oldProject = null;

	/**
	 * Used to store the child element named "old", which is under the 
	 * JDiff task XML element.
	 */
	public void addConfiguredOld(ProjectInfo projInfo) {
		oldProject = projInfo;
	}
	public ProjectInfo getConfiguredOld() {
		return oldProject;
	}

	/**
	 * A ProjectInfo-derived object for the newer version of the project
	 */
	private ProjectInfo newProject = null;

	/**
	 * Used to store the child element named "new", which is under the 
	 * JDiff task XML element.
	 */
	public void addConfiguredNew(ProjectInfo projInfo) {
		newProject = projInfo;
	}
	
	public ProjectInfo getConfiguredNew() {
		return newProject;
	}
	
	/** 
	 * The destination directory for the generated report.
	 * The default is "./jdiff_report".
	 */
	private File destdir = new File("jdiff_report");

	/**
	 * Used to store the destdir attribute of the JDiff task XML element.
	 */
	public void setDestdir(File value) {
		this.destdir = value;
	}

	public File getDestdir() {
		return this.destdir;
	}
	
	/**
	 * The classpath used by Javadoc to find jdiff.jar and xerces.jar.
	 */
	//private String jdiffClassPath = "(not set)";

	public String getJdiffClassPath() {
		return System.getProperties().getProperty("java.class.path");
	}
	
	/**
	 * JDIFF_HOME must be set as a property in the Ant build file.
	 * It should be set to the root JDiff directory, ie. the one where 
	 * jdiff.jar is found.
	 */
	//private String jdiffHome = "(not set)";

	public String getJdiffHome() {
		return System.getProperties().getProperty("user.dir");//return "user.dir";
	}
	
	/** 
	 * Add statistics to the report if set. Default can only be false.
	 */ 
	private boolean stats = false;

	public void setStats(boolean value) {
		this.stats = value;
	}

	public boolean getStats() {
		return this.stats;
	}
	
	/** 
	 * Add the -docchanges argument, to track changes in Javadoc documentation
	 * as well as changes in classes etc.
	 */ 
	private boolean docchanges = false;

	public void setDocchanges(boolean value) {
		this.docchanges = value;
	}

	public boolean getDocchanges() {
		return this.docchanges;
	}

}
